package com.chen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chen.entity.AccountB;
import com.chen.mapper.AccountBMapper;
import com.chen.service.AccountBService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

@Service
public class AccountBServiceImpl extends ServiceImpl<AccountBMapper,AccountB> implements AccountBService {
    @Resource
    private AccountBMapper accountBMapper;

    @Override
    public int frozenRmbAmount(int userId, BigDecimal rmbAmount) {
        return accountBMapper.frozenRmbAmount(userId,rmbAmount);
    }

    @Override
    public void commitRmbToRmb(int userId, BigDecimal rmbAmount) {
        accountBMapper.commitRmbToRmb(userId,rmbAmount);
    }

    @Override
    public void cancelRmbToRmb(int userId, BigDecimal rmbAmount) {
        accountBMapper.cancelRmbToRmb(userId,rmbAmount);
    }

    @Override
    public AccountB getByUserId(int userId) {
        LambdaQueryWrapper<AccountB>  queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AccountB::getUserId,userId);
        return this.getOne(queryWrapper);
    }
}
